home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group93b.txt / 000135_icon-group-sender _Mon Jun 7 21:49:33 1993.msg < prev    next >
Internet Message Format  |  1993-06-16  |  2KB

  1. Received: from owl.CS.Arizona.EDU by cheltenham.CS.Arizona.EDU; Mon, 14 Jun 1993 09:36:26 MST
  2. Received: by owl.cs.arizona.edu; Mon, 14 Jun 1993 09:36:25 MST
  3. Date: 7 Jun 93 21:49:33 GMT
  4. From: agate!howland.reston.ans.net!math.ohio-state.edu!caen!msuinfo!uchinews!ellis!goer@ucbvax.Berkeley.EDU  (Richard L. Goerwitz)
  5. Organization: University of Chicago
  6. Subject: Re: Pattern-Matching Help Request
  7. Message-Id: <1993Jun7.214933.25646@midway.uchicago.edu>
  8. References: <1993Jun7.174910.21523@wariat.org>
  9. Sender: icon-group-request@cs.arizona.edu
  10. To: icon-group@cs.arizona.edu
  11. Status: R
  12. Errors-To: icon-group-errors@cs.arizona.edu
  13.  
  14. ppetto@wariat.org (Peter J. Petto) writes:
  15. >
  16. >I'm looking for something that will test a string for a pattern
  17. >analgous to the following regular expression:
  18. >
  19. >     %From [A-Za-z0-9.]\@
  20.  
  21. You probably mean:
  22.  
  23.       %From [A-Za-z0-9.]*@
  24.  
  25. Somewhere you should say namechars := &letters ++ &digits ++ '.' so you
  26. can use this identifier the same as you would [A-Za-z0-9].  The key is that
  27. tab(many(x)) in Icon is the standard idiom for "move forward from the cur-
  28. rent position up to the first character not in x."  The next matching func-
  29. tion then picks up where tab(many(x)) leaves off:
  30.     
  31.     if line ? (="%From ", tab(many(namechars)), ="@")
  32.     then...
  33.  
  34. Icon's string scanning functions are a bit more verbose than regular expres-
  35. sions, for better or for worse - but far more powerful.  Conversion is always
  36. trivial once you get the hang of things.  Icon sacrifices terseness and some
  37. speed for power, elegance, and consistency with the rest of the language.
  38.  
  39. But I guess this is turning into a commentary on the relative merits of var-
  40. ious string-matching (sub-)languages.
  41.  
  42. >I'd appreciate any and all assistance.  Thanks.
  43.  
  44. Hope I helped.
  45.  
  46. -- 
  47.  
  48.    -Richard L. Goerwitz              goer%midway@uchicago.bitnet
  49.    goer@midway.uchicago.edu          rutgers!oddjob!ellis!goer
  50.